# -*- coding: utf-8 -*-
import sys,os
from .core import *

class Func:
    @staticmethod
    def File_Path(file=""):
        return os.path.split(os.path.realpath(file))[0]


    @staticmethod
    def get_module():

        def main_module_name():
            mod = sys.modules['__main__']
            file = getattr(mod, '__file__', None)
            return file and os.path.splitext(os.path.basename(file))[0]

        def modname(fvars):

            file, name = fvars.get('__file__'), fvars.get('__name__')
            if file is None or name is None:
                return None

            if name == '__main__':
                name = main_module_name()
            return name

        module_name = modname(globals())
        # print globals()
        # print module_name
        return module_name

def DIR(file=Module_Root):
    return os.path.split(os.path.realpath(file))[0]
def FILE(*file):
    return os.path.normpath(os.path.join(ROOT,*file))
def PATH(path):
    path= os.path.normpath(os.path.join(ROOT,path))
    sys.path.append(path)

def type(obj,type):
    return isinstance(obj, type)

def is_list(obj):
    return isinstance(obj, list)
def is_str(obj):
    return isinstance(obj, str)
def is_number(obj):
    return isinstance(obj, (int,float))
def isTrue(obj):
    if isinstance(obj,str):
        value=obj.lower()
        if value in ["false","","0"]:
            return False
        else:
            return True
    return bool(obj)
